
<template>
  <div class="itemNav">
    <div class="nav">
      <div class="left">
        <a
          href="javascript:void(0);"
          :class="index == isactive ? 'active' : ''"
          @click="handelchange(index)"
          :key="index"
          v-for="(item, index) in tablist"
          >{{ item.name }}
        </a>
      </div>
      <!-- <div class="right">
        <input type="text" placeholder="搜索" />

        <i class="icon"></i>
      </div> -->
    </div>
    <first :is="currentView" keep-alive @receive="receive"></first>
  </div>
</template>

<script>
import first from './projectTab/first.vue';
import second from './projectTab/second.vue';
import third from './projectTab/third.vue';
export default {
  name: 'ItemNav',
  data() {
    return {
      isactive: 0,
      tablist: [
        { name: '项目列表' },
        { name: '新建瀑布式项目' },
        { name: '新建敏捷项目' }
      ],
      currentView: 'first'
    };
  },
  components: {
    first,
    second,
    third
  },
  methods: {
    handelchange(index) {
      // console.log(index);
      this.isactive = index;
      if (index === 0) {
        this.currentView = 'first';
      } else if (index === 1) {
        this.currentView = 'second';
      } else if (index === 2) {
        this.currentView = 'third';
      } else {
        this.currentView = 'forth';
      }
    },
    receive() {
      console.log(111);
      this.isactive = 0;
      this.currentView = 'first';
    }
  }
};
</script>

<style lang="less" scoped>
.itemNav {
  width: 98%;
  margin: 0 auto;
  margin-top: 10px;
  padding-bottom: 20px;

  .nav {
    width: 100%;
    height: 45px;
    background: #ffffff;
    box-shadow: 0px 1px 2px 0px #b9b9b9;
    border-radius: 30px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      width: 600px;
      height: 35px;
      margin-left: 8px;
      display: flex;
      justify-content: space-between;
      align-content: center;
      // ul {
      //   width: 810px;
      //   height: 100%;
      //   display: flex;
      //   justify-content: space-between;
      //   align-content: center;

      //   li {
      //     width: 181px;
      //     height: 100%;
      //     text-align: center;
      //     font-size: 18px;
      //     font-family: PingFangSC-Medium, PingFang SC;
      //     font-weight: 500;
      //     color: #111111;
      //     line-height: 48px;
      //     background: linear-gradient(270deg, #1160cf 0%, #cd06bf 100%);
      //     border-radius: 26px;
      //   }
      // }
      a {
        height: 100%;
        text-align: center;
        font-size: 16px;
        line-height: 35px;
        border-radius: 26px;
        color: #000000;
        transition: all 0.3s;
        padding: 0 25px;
      }
      // a:hover {
      //   background: linear-gradient(270deg, #1160cf 0%, #cd06bf 100%);

      //   color: #ffffff;
      // }
      .active {
        background: linear-gradient(270deg, #1160cf 0%, #cd06bf 100%);
        box-shadow: 1px 0px 5px #1160cf, -1px 0px 5px #cd06bf;

        color: #ffffff;
      }
      a:hover {
        color: #fff;
        background-image: linear-gradient(270deg, #1160cf 0%, #cd06bf 100%);
        box-shadow: 1px 0px 5px #1160cf, -1px 0px 5px #cd06bf;
      }
    }
    .right {
      width: 250px;
      height: 40px;
      margin-right: 8px;
      background: linear-gradient(270deg, #1160cf 0%, #cd06bf 100%);
      border-radius: 40px;
      position: relative;

      input {
        outline: none;
        width: 242px;
        height: 34px;
        position: relative;
        border: 2px solid transparent;
        border-radius: 35px;
        background-clip: padding-box;
        text-align: center;
      }
      .icon {
        display: inline-block;
        width: 34px;
        height: 34px;
        line-height: 34px;
        text-align: center;
        background: url("~@/assets/searchicon.png") no-repeat center center;
        background-size: 100% 100%;
        border-radius: 50%;
        color: #fff;
        position: absolute;
        right: 3px;
        top: 3px;
      }
    }
  }
}
</style>>
